package com.dfbz.demo;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;

/**
 * @author lscl
 * @version 1.0
 * @intro:
 */
public class Demo01_Collection基本方法 {

    public static void main(String[] args) {

        Collection cities=new ArrayList();
        cities.add("湛江");
        cities.add("云浮");
        cities.add("东莞");


        Object[] arr = cities.toArray();

        System.out.println(Arrays.toString(arr));

    }
    public static void test2(String[] args) {
        Collection cities=new ArrayList();

        cities.add("肇庆");
        cities.add("汕头");
        cities.add("梅州");

        boolean flag = cities.contains("茂名");
        System.out.println(flag);           // false

        cities.add("茂名");
        flag = cities.contains("茂名");
        System.out.println(flag);           // true


        System.out.println(cities);
        cities.remove("汕头");
        System.out.println(cities);

    }

    public static void test(String[] args) {

        Collection cities=new ArrayList();

        cities.add("桂林");
        cities.add("丽江");
        cities.add("苏州");

        System.out.println(cities);
        System.out.println("--------------");

        System.out.println(cities.size());      // 3

        System.out.println(cities.isEmpty());   // false

        // 清空集合
        cities.clear();

        System.out.println(cities.isEmpty());   // true

    }
}
